package com.twu.biblioteca.model.menu;

import com.twu.biblioteca.model.IFactory;
import com.twu.biblioteca.model.session.Session;
import com.twu.biblioteca.presenter.Presenter;

/**
 * Created with IntelliJ IDEA.
 * User: cschlumb
 * Date: 16/08/2013
 * Time: 16:23
 * To change this template use File | Settings | File Templates.
 */
public class MenuItem implements IMenu {

    private final String name;
    private final IFactory<Presenter> presenterFactory;

    public MenuItem(String name, IFactory<Presenter> presenterFactory) {
        this.name = name;
        this.presenterFactory = presenterFactory;
    }

    @Override
    public void execute(Session session) {
        Presenter p = presenterFactory.get();
        p.go(session);
    }

    @Override
    public String toString() {
        return name;
    }
}
